var http = require("helper/http");
var circleUrl = require("url/circle");
var openHelper = require("helper/open");
var nf = sm("do_Notification");
var page = sm("do_Page");
var root = ui("$");

root.setMapping({
	"imgLogo.tag" : "bussId",//圈子加入申请id
	"imgLogo.source" : "logo",
	"alayoutLogo.tag" : "userId",
	"lableName.tag" : "imId",
	"lableName.text" : "name",
	"lableTime.text" : "time",
	"lableCircleName.tag" : "circleId",
	"lableCircleName.text" : "circleName"
});

//同意圈子加入申请
ui("btnAccept").on("touch", function(data, e) {
	var circleApplyId = ui("imgLogo").tag;
	http.post(circleUrl.url.apply.accept, {id:circleApplyId}, function(data) {
		page.fire("message_reflash_circle_apply", circleApplyId);
		nf.toast("接受申请成功");
	});
});

//忽略圈子加入申请
ui("btnIgnore").on("touch", function(data, e) {
	var circleApplyId = ui("imgLogo").tag;
	http.post(circleUrl.url.apply.ignore, {id:circleApplyId}, function(data) {
		page.fire("message_reflash_circle_apply", circleApplyId);
		nf.toast("已忽略");
	});
})

//点击头象
ui("alayoutLogo").on("touch", function(data, e) {
	var userId = ui("alayoutLogo").tag;//用户ID
	if(userId != null && userId !=""){
		openHelper.openPersonal(userId);
	}
})